package server.modules.generator.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import server.common.utils.PageUtils;
import server.common.utils.Query;

import server.modules.generator.dao.WorkGroupDao;
import server.modules.generator.entity.ProjectEntity;
import server.modules.generator.entity.WorkGroupEntity;
import server.modules.generator.service.WorkGroupService;
import server.modules.sys.entity.SysUserEntity;
import server.modules.sys.service.SysUserService;


@Service("workGroupService")
public class WorkGroupServiceImpl extends ServiceImpl<WorkGroupDao, WorkGroupEntity> implements WorkGroupService {
    @Autowired
    SysUserService sysUserService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WorkGroupEntity> page = this.page(
                new Query<WorkGroupEntity>().getPage(params),
                new QueryWrapper<WorkGroupEntity>()
        );

        for (WorkGroupEntity sing : page.getRecords()) {
            SysUserEntity sysUserEntity = sysUserService.getById(sing.getCreateUser());
            if (null != sysUserEntity)
                sing.setCreateUserName(sysUserEntity.getShowname());


        }

        return new PageUtils(page);
    }

}